
local loutai = fk.CreateSkill{
  name = "qsjx__loutai",
  tags = {"ready_skill"},
}

local DIY = require "packages/diy_utility/diy_utility"

Fk:loadTranslationTable{
  ["qsjx__loutai"] = "髅台",
  [":qsjx__loutai"] = "<a href='diy_ready_skill'>蓄势技</a>，出牌阶段，你可对攻击范围内的所有角色各造成1点伤害；你杀死一名角色后，重置此技能。",

  ["$qsjx__loutai1"] = "刘裕使臣骨作阶，髑髅台高接云天！",
  ["$qsjx__loutai2"] = "并州十万降卒颅，正缺新土筑京观！",
}

loutai:addEffect("active", {
  anim_type = "offensive",
  card_num = 0,
  target_num = 0,
  prompt = "点击确定，然后对攻击范围内所有角色各造成1点伤害",
  can_use = function(self, player)
    return player:getMark("@@lvshi_readying:::"..self.name) == 0
  end,
  card_filter = Util.FalseFunc,
  target_filter = Util.FalseFunc,
  on_use = function(self, room, effect)
    local player = effect.from
    local targets = table.filter(room:getAlivePlayers(), function (p) return player:inMyAttackRange(p) end)
    for _, p in ipairs(targets) do
      if player:isAlive() and p:isAlive() then
        room:damage({
          from = player,
          to = p,
          damage = 1,
          damageType = fk.NormalDamage,
          skillName = loutai.name,
        })
      end
    end
  end,
})

loutai:addEffect(fk.Deathed, {
  can_refresh = function(self, event, target, player, data)
    return player:hasSkill(loutai.name, true) and data.killer and data.killer == player
     and DIY.isReadying(player, loutai.name)
  end,
  on_refresh = function(self, event, target, player, data)
    DIY.resetReadySkill(player, loutai.name, loutai.name, true)
  end,
})

return loutai